<template>
	<view class="tab-bar">
		<block v-for="(item,index) in list" :key="index">
			<view class="tab-bar-item" :data-path="item.pagePath" :data-index="index" @click.stop="reLaunch">
				<image :src="selected == index ?item.selIconPath: item.iconPath"></image>
				<view :style="{'color': selected == index ? selectedColor:color}">{{item.text}}</view>
			</view>
		</block>
	</view>
</template>

<script>
	export default {
		props: {
			selected: {
				type: Number
			}
		},
		data() {
			return {
				color: "#707070",
				selectedColor: "#a61a32",
				list: [{
					pagePath: "/pages/index/index",
					text:"首页",
					iconPath: "/static/images/home.png",
					selIconPath:"/static/images/home-sel.png"
				},
				{
					pagePath: "/pages/illness/index",
					text:"病情",
					iconPath: "/static/images/illness.png",
					selIconPath:"/static/images/illness-sel.png"
				},
				{
					pagePath: "/pages/mine/index",
					text:"我的",
					iconPath: "/static/images/mine.png",
					selIconPath:"/static/images/mine-sel.png"
				}]
			}
		},
		methods: {
			reLaunch(e) {
				uni.reLaunch({
					url: e.currentTarget.dataset.path
				})
			}
		},
	}
</script>

<style scoped lang="scss">
	.tab-bar {
		width: 100%;
		position: fixed;
		bottom: 0;
		left: 0;
		height: 140rpx;
		border-top: 1rpx solid #F1F1F1;
		background-color: #fff;
		display: flex;
		justify-content: space-around;
		align-items: center;
		z-index: 998;
		.tab-bar-item {
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;
			image {
				width: 76rpx;
				height: 76rpx;
			}
		}
	}
</style>
